package main

import (
	"bufio"
	"fmt"
	"io"
	"net/http"
	"net/url"
)

func readBody(response *http.Response) []byte {
	reader := bufio.NewReader(response.Body)
	var res []byte
	for {
		temp := make([]byte, 100)
		_, err := reader.Read(temp)
		if err == io.EOF {
			break
		}
		res = append(res, temp...)
	}
	return res
}
func main() {
	proxyUrl, _ := url.Parse("http://10.168.124.17:8080/charge-attract-customer-platform/")
	t := &http.Transport{
		Proxy: http.ProxyURL(proxyUrl),
	}
	client := &http.Client{
		Transport: t,
	}
	request, err := http.NewRequest(http.MethodGet, "http://www.baidu.com", nil)
	if err != nil {
		fmt.Printf("err-->%v", err)
		return
	}
	response, err := client.Do(request)
	if err != nil {
		fmt.Printf("err-->%v", err)
		return
	}
	res := readBody(response)
	fmt.Println(string(res))

}
